package leets.leet2352;

public class Solution {
    public int equalPairs(int[][] grid) {
        int[][] nums=new int[grid.length][grid[0].length];
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[0].length; j++) {
                nums[i][j]=grid[j][i];
            }
        }
        int num=0;
        for (int i = 0; i < grid.length; i++) {

            for (int[] ints : grid) {
                if (arrEqual(nums[i], ints)) {
                    num++;
                }
            }
        }
        return num;
    }
    public boolean arrEqual(int[] a1,int[] a2){
        for (int i = 0; i < a1.length; i++) {
            if(a1[i]!=a2[i]){
                return false;
            }
        }
        return true;
    }
}
